Fix module mode linking on macOS#697
Open
ChrisJefferson wants to merge 1 commit intomlua-rs:mainfrom
Open
Conversation
When building a Lua C module (cdylib with the `module` feature) on macOS, the linker fails with undefined symbols for the Lua API. This is because macOS requires explicit `-undefined dynamic_lookup` to allow unresolved symbols in shared libraries — unlike Linux which permits them by default. The build script already had platform-specific handling for Windows (raw-dylib linking). This adds the equivalent for macOS, passing the required linker flags so that Lua symbols are resolved at load time from the host interpreter. Fixes the issue reported in mlua-rs#625.
Member
|
I don't think this is going to work well. The build script should be in each module, not inside mlua-sys. $ (cd tests/module && cargo build --release --features lua55)
warning: mlua-sys@0.11.0-rc.1: cargo:rustc-cdylib-link-arg was specified in the build script of mlua-sys v0.11.0-rc.1 (/Users/alex/Projects/mlua-rs/mlua/mlua-sys), but that package does not contain a cdylib target
Allowing this was an unintended change in the 1.50 release, and may become an error in the future. For more information, see <https://github.com/rust-lang/cargo/issues/9562>. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When building a Lua C module (cdylib with the
modulefeature) on macOS, the linker fails with undefined symbols for the Lua API. This is because macOS requires explicit-undefined dynamic_lookupto allow unresolved symbols in shared libraries — unlike Linux which permits them by default.The build script already had platform-specific handling for Windows (raw-dylib linking). This adds the equivalent for macOS, passing the required linker flags so that Lua symbols are resolved at load time from the host interpreter.
Fixes the issue reported in #625 -- I didn't find that PR until after I fixed it because it's closed, do you mind putting it in the source?